package com.demo1_两数之和;

public class Test_2024_02_25 {
    public static void main(String[] args) {
        int[] arr={1,2,5,8,9,41,5};
        int num=11;
        int[] result=new Test_2024_02_25().twoSum(arr,num);
        System.out.println(result[0]+" "+result[1]);
    }
    public static int[] twoSum(int[] nums, int target) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = i+1; j < nums.length; j++) {
                if (nums[i]+nums[j]==target){
                    return new int[]{i,j};
                }
            }
        }
        return null;
    }
}
